var e = require;
var t = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("NotifyEventType"),
    a = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("ModuleUI"),
    s = e("Game"),
    l = e("RoleSoldierInfo"),
    c = e("HeroInfoViewUI"),
    d = cc._decorator,
    h = d.ccclass,
    _ = d.property,
    u = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.card_content_view = null),
                (t.card_node_item = null),
                (t.top_btn_view = null),
                (t.gray_material = null),
                t
            );
        }
        return (
            __extends(t, e),

            (t.prototype.onDisable = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();

            }),
            

            (t.prototype.initView = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();
                Adv_skd.default.instance.showGridAdLeftOne();
                Adv_skd.default.instance.showGridAdRightOne();
                Adv_skd.default.instance.showInterstitialAd();
                

                e.prototype.initView.call(this);
                for (var t = s.default.shop_role_info, o = 0; o < a.GlobalParams.GameHeroIndex.length; o++) {
                    var n = a.GlobalParams.GameHeroIndex[o],
                        r = l.default.Role_info[t[n].id],
                        c = cc.instantiate(this.card_node_item);
                    (c.getComponent(cc.Sprite).spriteFrame = i.default.getInstance().getHeroCardFrame(r.C_ID)),
                        (c.getChildByName("hero_name").getComponent(cc.Label).string = r.C_Name),
                        (c.getChildByName("hero_type").getComponent(cc.Label).string =
                            0 == r.C_type ? "近战英雄" : "远程英雄"),
                        (c.name = "card_item_" + r.C_type + "_" + n),
                        -1 == a.GlobalParams.playerSkinInfo.value.have.hero.indexOf(n) &&
                            c.getComponent(cc.Sprite).setMaterial(0, this.gray_material),
                        (c.active = !0),
                        this.card_content_view.addChild(c),
                        c.on("click", this.showHeroCardInfo, this);
                }
                this.showCardInfo("all");
            }),
            (t.prototype.OnClick = function (t) {
                switch ((e.prototype.OnClick.call(this, t), t.node.name)) {
                    case "back_btn":
                        this.emitEvent(n.default.SEND_BOX_PORTAL_INFO, !0), this.node.destroy();
                        break;
                    case "all_btn":
                        this.showCardInfo("all");
                        break;
                    case "near_btn":
                        this.showCardInfo("near");
                        break;
                    case "far_btn":
                        this.showCardInfo("far");
                }
            }),
            (t.prototype.showCardInfo = function (e) {
                this.card_content_view.parent.parent.getComponent(cc.ScrollView).scrollToLeft(0.1);
                for (var t = 0, o = this.card_content_view.children; t < o.length; t++) {
                    var n = o[t];
                    n.active =
                        "all" == e ||
                        ("near" == e && "0" == n.name.substring(10, 11)) ||
                        ("far" == e && "1" == n.name.substring(10, 11));
                }
                (this.top_btn_view.children[0].children[1].active = "all" == e),
                    (this.top_btn_view.children[1].children[1].active = "near" == e),
                    (this.top_btn_view.children[2].children[1].active = "far" == e);
            }),
            (t.prototype.showHeroCardInfo = function (e) {
                var t = e.node.name,
                    o = Number(t.substring(12, t.length));
                this.uiManager.showPopup("HeroInfoViewUI", function (e) {
                    e.getComponent(c.default).showHeroInfo(o);
                });
            }),
            __decorate([_(cc.Node)], t.prototype, "card_content_view", void 0),
            __decorate([_(cc.Node)], t.prototype, "card_node_item", void 0),
            __decorate([_(cc.Node)], t.prototype, "top_btn_view", void 0),
            __decorate([_(cc.Material)], t.prototype, "gray_material", void 0),
            __decorate([h], t)
        );
    })(r.default);
o.default = u;
